Skip to content

feat: 引入 ToolManager 权限执行骨架与统一 Action 模型#109

Merged
minorcell merged 4 commits into
1024XEngineer:mainfrom
Cai-Tang-www:main
Apr 1, 2026
Merged

feat: 引入 ToolManager 权限执行骨架与统一 Action 模型#109
minorcell merged 4 commits into
1024XEngineer:mainfrom
Cai-Tang-www:main

Conversation

@Cai-Tang-www

@Cai-Tang-www Cai-Tang-www commented Apr 1, 2026

Copy link
Copy Markdown
Collaborator

背景

围绕 #98 / #106,本次先落地工具与安全方向的第一阶段基础骨架。

是先把统一执行入口、统一权限模型和后续扩展点立住,避免后续继续在 runtime / tools 间重复重构。

本次改动

  • 引入 internal/security
  • 建立统一 Action 模型与 Decision / Rule / PermissionEngine
  • 将权限检查入口统一为:PermissionEngine.Check(Action)
  • 引入 ToolManager 抽象
  • 将执行链收敛为:
runtime
  -> ToolManager
    -> PermissionEngine
    -> WorkspaceSandbox
    -> Executor
  • 当前 WorkspaceSandbox 先提供显式骨架与 noop 实现,为后续目录边界与敏感路径保护预留插口
  • Runtime 不再直接依赖具体工具注册表执行工具,而是依赖 tools.Manager
  • 为 built-in tools 建立第一版 action 映射:
    • bash
    • filesystem_read_file
    • filesystem_write_file
    • filesystem_edit
    • filesystem_grep
    • filesystem_glob
    • webfetch
  • 为未来 MCP 接入预留统一模型:
    • mcp.server
    • mcp.server.tool
    • MCP 不允许绕过统一权限层

影响

  • 当前主链路保持可用
  • 默认策略仍为 allow,不改变现有 built-in tool 的默认行为
  • 本次主要是架构收口与安全骨架落地,不引入审批 UI 和重型沙箱

测试

已补充并通过以下测试:

  • internal/security
  • internal/tools
  • internal/runtime
  • internal/app

本地验证:

go test ./...

Refs

@codecov

codecov Bot commented Apr 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.81882% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/tools/manager.go 94.39% 3 Missing and 3 partials ⚠️
internal/app/bootstrap.go 73.33% 2 Missing and 2 partials ⚠️
internal/tools/permission_mapper.go 97.26% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@Cai-Tang-www Cai-Tang-www requested a review from wynxing April 1, 2026 13:45
@minorcell minorcell merged commit e6caa9e into 1024XEngineer:main Apr 1, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(security/tools): P0-1 引入 Tool Manager 骨架与 Permission Gateway 规则模型

2 participants